/*
@author: user
@date: 2022/6/6 18:24
@Version: 1.0
@last modifined by : 2022/6/6 18:24
@last Modifined time : 2022/6/6 18:24
*/

import React from 'react';
import { connect } from 'react-redux';
import { getThemeContext } from '@/store/themeContext';
import ThemeSkinning from '@C/ThemeSkinning';
import CopyrightStatement from '@C/CopyrightStatement';
// import { getMovieData } from '@S/asyncAction/movie';
// import { categories, preferentialstatus } from '@/api/mock';
import { test } from '@/api';

const Dashboard = (props) => {
  // const { dispatch } = props;
  // const [productList, setProductList] = useState([]);
  const themeContext = getThemeContext();
  console.log('themeContext: ', themeContext);
  test().then((res) => {
    console.log('test res: ', res);
  })

  // TODO: 这里获取 无印良品 官网接口作为 Mock 数据
  // useEffect(() => {
  //   categories()
  //     .then((res = {}) => {
  //       const { data: { list = [] } = {}, code } = res;
  //       if (code) return;
  //       setProductList(
  //         list.map((item, idx) => {
  //           return {
  //             id: item?.id ?? idx,
  //             value: item?.id ?? 0,
  //             label: item?.cateName ?? '-',
  //           }
  //         })
  //       )
  //       console.log('get res: ', res);
  //     });
  //   preferentialstatus()
  //     .then((res = {}) => {
  //       console.log('post res: ', res);
  //     });
  // }, []);

  return (
    <>
      <div
        onClick={() => {
          // dispatch(getMovieData('哈哈哈， 我是测试'));
          // dispatch({ type: 'movie/getMovie/fulfilled', payload: '这个 payload 可能用于派发其它额外参数，但不建议这么干' });
        }}
      >
        <h3>主页仪表板</h3>
        {/* {
          productList.map((item, idx) => {
            return <h3 key={`${item.id}-${idx}`}>{ item.label }</h3>
          })
        }*/}
      </div>
      <ThemeSkinning { ...props } />
      <CopyrightStatement />
    </>
  );
};

export default connect(() => {
  return {
    // value: state.counter.value,
  };
})(Dashboard);
